package com.souvc.xstream;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import com.thoughtworks.xstream.converters.basic.BooleanConverter;
import com.thoughtworks.xstream.converters.extended.ToAttributedValueConverter;

import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;

/**
 * 测试 Field as Text Value
 */
@XStreamAlias("message")
@XStreamConverter(value=ToAttributedValueConverter.class, strings={"content"})
public class RendezvousMessage9 {

    @XStreamAlias("type")
    @XStreamAsAttribute
    private int messageType;

    //要注意的是，不能是List了 观察 RendezvousMessage10有何不同
    private List<String> content;

    @XStreamConverter(value=BooleanConverter.class, booleans={false}, strings={"yes", "no"})
    private boolean important;

    @XStreamConverter(SingleValueCalendarConverter.class)
    private Calendar created = new GregorianCalendar();

    public RendezvousMessage9(int messageType, boolean important, String... content) {
        this.messageType = messageType;
        this.important = important;
        this.content = Arrays.asList(content);
    }
}
